package in.srain.cube.util.time;

import android.text.TextUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class DateFormat {

    private static final SimpleDateFormat DATE_FORMAT;
    private static final SimpleDateFormat DATE_FORMAT2;


    static {
        DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+8"));

        DATE_FORMAT2 = new SimpleDateFormat("MM-dd HH:mm");
        DATE_FORMAT2.setTimeZone(TimeZone.getTimeZone("GMT+8"));
    }

    public static String format(Date date) {
        return DATE_FORMAT.format(date);
    }

    public static String format2(Date date) {
        return DATE_FORMAT2.format(date);

    }

    public static Date parse(String str) {
        if (TextUtils.isEmpty(str)) {
            return new Date();
        }
        try {
            return DATE_FORMAT.parse(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Date();
    }
}
